<template>
  <Teleport to="body">
    <div class="mask">
      <div class="dalog">
        <h3>我是一个 Dalog</h3>
        <p>这是一些 MSG</p>
        <button @click="closeDalog">关闭</button>
      </div>
    </div>
  </Teleport>
</template>

<script>
import { inject } from 'vue'
export default {
  name: 'Dalog-Comp',
  setup() {
    let closeDalog = inject('closeDalog');
    return {
      closeDalog
    }
  }
}
</script>

<style>
.mask {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(0, 0, 0, 0.4);


}

.dalog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: chartreuse;
  padding: 20px;
  width: 300px;
  height: 200px;
  text-align: center;
}
</style>
